<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%--
<!DOCTYPE html>--%>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>分店页面</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" type="image/png" href="/resources/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="/resources/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <script src="/resources/js/echarts.min.js"></script>
    <link rel="stylesheet" href="/resources/css/amazeui.min.css"/>
    <link rel="stylesheet" href="/resources/css/amazeui.datatables.min.css"/>
    <link rel="stylesheet" href="/resources/css/app.css">
    <script src="/resources/js/jquery.min.js"></script>


</head>

<body data-type="table">
<script src="/resources/js/theme.js"></script>
<div class="am-g tpl-g">

    <%--头部开始--%>
    <%@include file="header.jsp" %>
    <%--头部结束--%>


    <!-- 内容区域 -->
    <div class="tpl-content-wrapper">
        <div class="row-content am-cf">
            <div class="row">
                <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                    <div class="widget am-cf">
                        <div class="container-fluid am-cf">
                            <div class="row">
                                <div class="am-u-sm-12 am-u-md-12 am-u-lg-9">
                                    <div class="page-header-heading"><span
                                            class="am-icon-flag page-header-heading-icon"></span> 分店信息
                                        <small>Stores Information</small>
                                    </div>
                                    <p class="page-header-description">对分店信息增加、修改、删除、等操作。</p>
                                </div>
                                <div class="am-u-lg-3 tpl-index-settings-button">
                                    <%--<button type="button" class="page-header-button"><span class="am-icon-paint-brush"></span> 设置</button>--%>
                                </div>
                            </div>
                        </div>

                        <div class="widget-body  am-fr">

                            <!-- 编辑栏 -->
                            <div class="am-u-sm-12 am-u-md-6 am-u-lg-6">
                                <div class="am-form-group">
                                    <div class="am-btn-toolbar">
                                        <div class="am-btn-group am-btn-group-xs">
                                            <button type="button"
                                                    class="am-btn am-btn-default am-btn-success submitAddBranBtn"
                                                    onclick="hideBtn();showUpper();showEmpolyeeType();"
                                                    data-am-modal="{target: '#formModel', width: 900}"><span
                                                    class="am-icon-plus"></span> 新增
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!-- 下拉框 -->
                            <div class="am-u-sm-12 am-u-md-6 am-u-lg-3">
                                <div class="am-form-group tpl-table-list-select">
                                    <select id="searchType" data-am-selected="{btnSize: 'sm'}">
                                        <option value="branName">分店名</option>
                                        <%--<option value="emName">负责人</option>--%>
                                        <option value="branPrinciple">负责人编号</option>
                                    </select>
                                </div>
                            </div>
                            <!-- 搜索框 -->
                            <div class="am-u-sm-12 am-u-md-12 am-u-lg-3">
                                <div class="am-input-group am-input-group-sm tpl-form-border-form cl-p">
                                    <input type="text" class="am-form-field " id="searchContent">
                                    <span class="am-input-group-btn">
                                            <button class="am-btn  am-btn-default am-btn-success tpl-table-list-field am-icon-search"
                                                    id="searchBtn" type="button"></button>
                                          </span>
                                </div>
                            </div>
                            <!-- 表格显示 -->
                            <div class="am-u-sm-12 tableDiv" >
                                <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black "
                                       id="example-r">
                                    <thead>
                                    <tr>
                                        <th class="am-text-center">分店名称</th>
                                        <th class="am-text-center">父店</th>

                                        <th class="am-text-center">分店地址</th>
                                        <%-- <th class="am-text-center">分店信息</th>--%>
                                        <th class="am-text-center">分店图片</th>

                                        <%--<th class="am-text-center">分店营业额</th>
                                        <th class="am-text-center">分店月营业额</th>--%>

                                        <th class="am-text-center">分店负责人</th>
                                        <th class="am-text-center">分店营业状况</th>
                                        <th class="am-text-center">加盟日期</th>
                                        <th class="am-text-center">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>

                                    <c:forEach items="${pageInfo.list }" var="bl">
                                        <tr class="am-text-center">
                                            <td>${bl.subShop.branName}</td>
                                            <td>
                                                    ${bl.parentShop}
                                            </td>
                                            <td>${bl.subShop.branAddress}</td>
                                            <td>
                                                <a
                                                        href="#"
                                                        onclick="showPhotoFun('${bl.subShop.branId}');"
                                                        data-am-modal="{target: '#showPictureModel', closeViaDimmer: 0, width: '400px', height: '500px'}">
                                                    图片
                                                </a>
                                            </td>
                                                <%--分店负责人--%>
                                            <td>
                                                    ${bl.employee.emName}
                                            </td>

                                            <td>
                                                <c:choose>
                                                    <c:when test="${bl.subShop.branState == 1}">正常营业</c:when>
                                                    <c:when test="${bl.subShop.branState == 0}">未营业 </c:when>
                                                </c:choose>
                                            </td>
                                            <td>
                                                    ${fn:substring(bl.subShop.joinDate, 0, 10)}
                                            </td>
                                            <td>
                                                <button type="button" class="am-btn am-btn-xs am-btn-success"
                                                        onclick="getEmp('${bl.subShop.branId}')"
                                                    <span class="am-icon-eye"></span> 查看分店员工
                                                </button>
                                                <button type="button" class="am-btn am-btn-xs am-btn-warning"
                                                        onclick="window.open('/count/branch?br=' + ${bl.subShop.branId});">
                                                    <span class="am-icon-eye"></span> 报表查看
                                                </button>
                                                <button type="button" class="am-btn am-btn-xs am-btn-secondary"
                                                        onclick="editBranBtn('${bl.subShop.branId}')"
                                                        data-am-modal="{target: '#formModel', width: 900}">
                                                    <span class="am-icon-eye"></span> 查看
                                                </button>
                                                <button type="button" class="am-btn am-btn-xs am-btn-danger"
                                                        onclick="delBranBtn('${bl.subShop.branId}')">
                                                    <span class="am-icon-trash-o"></span> 删除
                                                </button>
                                            </td>
                                        </tr>
                                    </c:forEach>
                                    <!-- more data -->
                                    </tbody>
                                </table>
                            </div>

                            <!-- 分页开始 -->
                            <div class="am-u-lg-12 am-cf">

                                <!-- 分页文字信息，其中分页信息都封装在pageInfo中 -->
                                <div class="col-md-6">
                                    当前第：${pageInfo.pageNum }页，总共：${pageInfo.pages }页，总共：${pageInfo.total }条记录
                                </div>
                                <div class="am-fr">
                                    <ul class="am-pagination tpl-pagination">
                                        <!-- 首页 -->
                                        <li><a href="/branchesController/findBranches?pn=1">首页</a></li>
                                        <!-- 上一页 -->
                                        <c:if test="${pageInfo.hasPreviousPage }">
                                            <li>
                                                <a href="/branchesController/findBranches?pn=${pageInfo.pageNum-1 }"
                                                   aria-label="Previous">
                                                    <span aria-hidden="true">&laquo;</span>
                                                </a>
                                            </li>
                                        </c:if>
                                        <!-- 循环遍历连续显示的页面，若是当前页就高亮显示，并且没有链接 -->
                                        <c:forEach items="${pageInfo.navigatepageNums }" var="page_Num">
                                            <c:if test="${page_Num == pageInfo.pageNum }">
                                                <li class="am-active"><a
                                                        href="/branchesController/findBranches?pn=${page_Num }">${page_Num }</a>
                                                </li>
                                            </c:if>
                                            <c:if test="${page_Num != pageInfo.pageNum }">
                                                <li>
                                                    <a href="/branchesController/findBranches?pn=${page_Num }">${page_Num }</a>
                                                </li>
                                            </c:if>
                                        </c:forEach>
                                        <!-- 下一页 -->
                                        <c:if test="${pageInfo.hasNextPage }">
                                            <li>
                                                <a href="/branchesController/findBranches?pn=${pageInfo.pageNum+1 }"
                                                   aria-label="Next">
                                                    <span aria-hidden="true">&raquo;</span>
                                                </a>
                                            </li>
                                        </c:if>
                                        <!-- 末页 -->
                                        <li><a href="/branchesController/findBranches?pn=${pageInfo.pages }">末页</a></li>
                                    </ul>
                                </div>
                            </div>
                            <!-- 分页结束 -->

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>
<script>
    function getEmp(branid) {
        window.open("/employeeController/findbrEmployee?branch="+branid);
    }

</script>

<!-- 模态框开始 -->
<div class="am-modal am-modal-no-btn" tabindex="-1" id="formModel">
    <div class="am-modal-dialog">
        <div class="am-modal-bd" style="padding: 2px;">
            <div class="row">
                <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                    <div class="widget am-cf" style="margin: 0;">
                        <div class="widget-head am-cf">
                            <div class="widget-title am-fl"><h2>分店录入表单</h2></div>
                            <div class="widget-function am-fr">
                                <a href="javascript: void(0)" class="am-close am-close-spin clearForm">&times;</a>
                            </div>
                        </div>
                        <div class="widget-body am-fr">
                            <!-- 分店信息录入 -->
                            <form class="am-form tpl-form-border-form tpl-form-border-br" id="branchesForm">

                                <!-- 分店ID -->
                                <div class="am-form-group am-hide">
                                    <label class="am-u-sm-3 am-form-label">分店ID</label>
                                    <div class="am-u-sm-6">
                                        <input type="text" name="branId" class="am-form-field tpl-form-no-bg branId"/>
                                    </div>
                                    <div class="am-u-sm-3">
                                    </div>
                                </div>

                                <!-- 分店图片 -->
                                <div class="am-form-group">
                                    <label class="am-u-sm-3 am-form-label">分店图片</label>
                                    <div class="am-u-sm-6">
                                        <div class="tpl-form-file-img">
                                            <img class="imagePhoto" style="width: 330px; height: 270px;">
                                        </div>
                                        <br>
                                        <div class="am-form-group am-form-file">
                                            <button type="button" class="am-btn am-btn-danger am-btn-sm">
                                                <i class="am-icon-cloud-upload"></i> 上传分店图片
                                            </button>
                                            <input type="file" class="addBranPhoto">
                                            <input type="text" name="branPhoto" class="am-hide strPhoto">
                                        </div>
                                    </div>
                                    <div class="am-u-sm-3">
                                        <small class="tipstrPhoto">请上传分店图片！</small>
                                    </div>
                                </div>

                                <!-- 父店-->
                                <div class="am-form-group ">
                                    <label class="am-u-sm-3 am-form-label">父店</label>
                                    <div class="am-u-sm-6">
                                        <select name="upperId" class="upperId" data-am-selected="{searchBox: 1}">
                                            <%--<option value="1">父店1</option>
                                            <option value="2">父店2</option>
                                            <option value="3">父店3</option>
                                            <option value="4">父店4</option>--%>
                                        </select>
                                    </div>
                                    <div class="am-u-sm-3">
                                        <small class="tipUpperId">此项为必填项！</small>
                                    </div>
                                </div>

                                <!-- 分店名称-->
                                <div class="am-form-group ">
                                    <label class="am-u-sm-3 am-form-label">分店名称</label>
                                    <div class="am-u-sm-6">
                                        <input type="text" name="branName" class="am-form-field tpl-form-no-bg branName"
                                               placeholder="请输入分店名称(仅限10个字符)" required="required" maxlength="10"/>
                                    </div>
                                    <div class="am-u-sm-3">
                                        <small class="tipBranName">此项为必填项！</small>
                                    </div>
                                </div>

                                <!-- 分店地址-->
                                <div class="am-form-group ">
                                    <label class="am-u-sm-3 am-form-label">分店地址</label>
                                    <div class="am-u-sm-6">
                                        <input type="text" name="branAddress"
                                               class="am-form-field tpl-form-no-bg branAddress " maxlength="30"
                                               placeholder="请输入分店地址(仅限30个字符)"
                                               required="required"/>
                                    </div>
                                    <div class="am-u-sm-3">
                                        <small class="tipBranAddress">此项为必填项！</small>
                                    </div>
                                </div>

                                <!-- 分店营业额-->
                                <%--<div class="am-form-group " >
                                    <label class="am-u-sm-3 am-form-label">营业额</label>
                                    <div class="am-u-sm-6">
                                        <input type="text" name="turnover" class="am-form-field tpl-form-no-bg turnover" placeholder="请输入分店营业额"  required="required" />
                                    </div>
                                    <div class="am-u-sm-3">
                                        <small class="tipTurnover">此项为必填项！</small>
                                    </div>
                                </div>

                                <!-- 分店月营业额-->
                                <div class="am-form-group " >
                                    <label class="am-u-sm-3 am-form-label">月营业额</label>
                                    <div class="am-u-sm-6">
                                        <input type="text" name="monthTurnover" class="am-form-field tpl-form-no-bg monthTurnover" placeholder="请输入分店月营业额"  required="required" />
                                    </div>
                                    <div class="am-u-sm-3">
                                        <small class="tipMonthTurnover">此项为必填项！</small>
                                    </div>
                                </div>--%>

                                <!-- 分店是否营业-->
                                <div class="am-form-group ">
                                    <label class="am-u-md-2 am-u-lg-3 am-form-label">营业状况</label>
                                    <div class="am-u-md-4 am-u-lg-6">
                                        <div class="am-form-group">
                                            <label class="am-radio-inline">
                                                <input type="radio" name="branState" class="branState" value="1"
                                                       checked="checked">正常营业
                                            </label>
                                            <label class="am-radio-inline">
                                                <input type="radio" name="branState" class="branState" value="0"> 未营业
                                            </label>
                                        </div>
                                    </div>
                                    <div class="am-u-md-1 am-u-lg-3">
                                        <small style="color: green">√</small>
                                    </div>
                                </div>
                                <!-- 加盟日期 -->
                                <div class="am-form-group">
                                    <label class="am-u-sm-3 am-form-label">加盟日期</label>
                                    <div class="am-u-sm-6">
                                        <div class="am-input-group am-datepicker-date"
                                             data-am-datepicker="{format: 'yyyy-mm-dd', viewMode: 'years'}">
                                            <input type="text" class="am-form-field joinDate" name="joinDate"
                                                   placeholder="请选择加盟日期" readonly>
                                            <span class="am-input-group-btn am-datepicker-add-on">
                                                <button class="am-btn am-btn-default" type="button">
                                                    <span class="am-icon-calendar"></span>
                                                </button>
                                            </span>
                                        </div>
                                    </div>
                                    <div class="am-u-sm-3">
                                        <small class="tipJoinDate">此项为必填项！</small>
                                    </div>
                                </div>

                                <!-- 分店负责人-->
                                <div class="am-form-group ">
                                    <label class="am-u-sm-3 am-form-label">负责人 </label>
                                    <div class="am-u-sm-6">
                                        <select name="branPrinciple" class="branPrinciple"
                                                data-am-selected="{searchBox: 1}">
                                            <%--<option value="1">负责人1</option>
                                            <option value="2">负责人2</option>
                                            <option value="3">负责人3</option>
                                            <option value="4">负责人4</option>--%>
                                        </select>
                                    </div>
                                    <div class="am-u-sm-3">
                                        <small class="tipBranPrinciple">此项为必填项！</small>
                                    </div>
                                </div>

                                <!-- 分店信息-->
                                <div class="am-form-group ">
                                    <label class="am-u-sm-3 am-form-label">分店信息</label>
                                    <div class="am-u-sm-6">
                                        <textarea rows="5" name="branInfo" class="am-form-field tpl-form-no-bg branInfo"
                                                  placeholder="输入的信息请在200字之内！" maxlength="200"></textarea>
                                    </div>
                                    <div class="am-u-sm-3">
                                        <small class="tipBranInfo"></small>
                                    </div>
                                </div>

                                <!-- 按钮 -->
                                <div class="am-form-group">
                                    <div class="am-u-sm-12">
                                        <button type="button"
                                                class="am-btn am-btn-secondary tpl-btn-bg-color-success clearForm"><i
                                                class="am-icon-close"></i> 取消
                                        </button>
                                        <button type="button" class="am-btn am-btn-success tpl-btn-bg-color-success"
                                                onclick="updateBranBtn();" id="updateBtn"><i
                                                class="am-icon-floppy-o"></i>
                                            更新
                                        </button>
                                        <button type="button" class="am-btn am-btn-success tpl-btn-bg-color-success "
                                                id="submitAddBranBtn"><i class="am-icon-floppy-o"></i> 提交
                                        </button>
                                    </div>
                                </div>
                            </form>

                        </div>
                    </div>
                </div>
            </div>
            <!-- 整个表单结束 -->
        </div>
    </div>
</div>
<!-- 模态框结束 -->
<!-- 删除分店提示警告框开始 -->
<div class="am-modal am-modal-confirm" tabindex="-1" id="delBranConfirm">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">删除警告</div>
        <div class="am-modal-bd">
            您，确定要删除这条记录吗？
        </div>
        <div class="am-modal-footer">
            <span class="am-modal-btn" data-am-modal-cancel>取消</span>
            <span class="am-modal-btn" data-am-modal-confirm>确定</span>
        </div>
    </div>
</div>
<!-- 删除分店提示警告框结束 -->
<!-- 查看图片模态框开始 -->
<div class="am-modal am-modal-no-btn" tabindex="-1" id="showPictureModel">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">
            分店图片
            <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
        </div>
        <div class="am-modal-bd">
            <div class="tpl-form-file-img">
                <img alt="未找到头像" class="imagePhoto" width="380px" height="440px">
            </div>
        </div>
    </div>
</div>
<!-- 查看图片 模态框结束 -->

<script src="/resources/js/amazeui.min.js"></script>
<script src="/resources/js/amazeui.datatables.min.js"></script>
<script src="/resources/js/dataTables.responsive.min.js"></script>
<script src="/resources/js/app.js"></script>
<script src="/resources/jsutlis/fileutli.js"></script>
<script src="/resources/js/branches.form.validation.js"></script>

</body>

</html>